Q: The let keyword cannot be used ___________
Solution: The let keyword can be used in four ways : as a variable declaration like var; in a for or for/in loop, as a substitute for var; as a block statement, to define new variables and explicitly delimit their scope; and to define variables that are scoped to a single expression.
Q: The main difference between the variables declared with var and with let is __________
Solution: Variables declared with var have global scope whereas variable declared with let have block scope. Variables declared with let are defined only within the closest enclosing block (and any blocks nested within it, of course).
Q: What would be the result or type of error if p is not defined in the following JavaScript code snippet? console.log(p)
Solution: Console.log() is a predefined function in javascript which is used to print data or message on the console. If the argument of the console.log is not defined it will give a reference error.
Q: What will be the output of the following JavaScript code? let x=x+1; console.log(x);
Solution: x has not been defined with any value hence the value of x+1 will be Nan. Therefore the console.log function will print NaN.
Q: What will be the output of the following JavaScript code? [x,y]=[y,x];
Solution: The above code snippet will flash an error message. This is due to the fact that the variables x and y are not defined.
Q: Which looping statement allows XML tags to appear in JavaScript programs and adds API for operating on XML data?
Solution: The for/each loop is a new looping statement standardized by E4X. E4X (ECMAScript for XML) is a language extension that allows XML tags to appear literally in JavaScript programs and adds syntax and API for operating on XML data.
Q: Which exception does the Iterators throw from their next() method when there are no more values to iterate, that work on finite collections?
Solution: Iterators that work on finite collections throw Stop Iteration from their next() method when there are no more values to iterate. Stop Iteration is a property of the global object in JavaScript 1.7. Its value is an ordinary object (with no properties of its own) that is reserved for this special purpose of terminating iterations. Note, in particular,that Stop Iteration is not a constructor function like TypeError() or RangeError().
Q: Which method of the iterable object returns an iterator object for the collection?
Solution: An iterable object represents a collection of values that can be iterated. An iterable object must define a method named __iterator__() (with two underscores at the start and end of the name) which returns an iterator object for the collection.
Q: What will be the output of the following JavaScript code?
Solution: The toExponential() method converts a number into an exponential notation. It displays the number of digit according to the input passed to it.
Q: What will be the output of the following JavaScript code?
Solution: NEGATIVE_INFINITY is a static property of the JavaScript Number object. Using x.NEGATIVE_INFINITY, where x is a number or a Number object, will return undefined.
You Have Score    | /10 |